home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / art&graf.ix / art-0015 / flicker / undermou.asm < prev    next >
Assembly Source File  |  1997-04-16  |  3KB  |  104 lines

  1.  
  2. ; :ts=10
  3.  
  4.     public _cscreen
  5.     public _mouse_x
  6.     public _mouse_y
  7.  
  8.     ;save_m()    save underneath mouse
  9.     public _save_m
  10. _save_m    
  11.     move.w    #15,d1    ;line count
  12.     move.b    d1,mouse_saved    ; set flag that says it's saved
  13.     move.l    #undermouse,a1    ; point a1 to save buffer
  14.     move.w    _mouse_y,d0    ; get y coordinate
  15.     sub.w    #8,d0    ; adjust for hot spot
  16.     bge    yposi    ; start clipping ... at least it's positive
  17.     cmp.w    #-16,d0    ; is it completely above screen?
  18.     bls    clipout
  19.     add.w    d0,d1    ; y negative a little, makes less than 16 lines...
  20.     move.w    #0,d0    ; and after clipping start at 0
  21.     bra    yaddr    ; and go calculate
  22. yposi    cmp.w    #200,d0    ; totally below screen?
  23.     bge    clipout
  24.     move.w    d0,d2
  25.     sub.w    #200-16,d2  ; # of lines off bottom of screen in d2
  26.     bls    yaddr    ; if negative or zero don't have to clip
  27.     sub.w    d2,d1    ; ready to draw a few less lines
  28. yaddr    move.w    d1,lines    ; save line count for restore
  29.     move.l    _cscreen,a0
  30.     lsl.w    #5,d0
  31.     adda.w    d0,a0
  32.     lsl.w    #2,d0    
  33.     adda.w    d0,a0    ; a0 = cscreen + 160*y
  34.     move.w    _mouse_x,d0    ; get x coordinate
  35.     sub.w    #8,d0    ; adjust for hot spot
  36.     bge    xposi    ; x is positive at least
  37.     cmp.w    #-16,d0    ; if negative is it offscreen entirely?
  38.     bls    clipout    
  39.     bra     leftedge 
  40. xposi    cmp.w    #320,d0    ; is it offscreen to right?
  41.     bge    clipout
  42.     cmp.w    #320-16,d0 ; partially right clipped?
  43.     bls    add_xadd
  44.     bra    rightedge    
  45. add_xadd    and.w    #$fff0,d0    
  46.     lsr.w    #1,d0
  47.     adda.w    d0,a0    ; point a0 to the right word even ... 
  48.     move.l    a0,firstword    ; save the address for restore
  49.     clr.b    one_word        ; hey, we're doing two words
  50.  
  51. s2loop    move.l    (a0)+,(a1)+
  52.     move.l    (a0)+,(a1)+
  53.     move.l    (a0)+,(a1)+
  54.     move.l    (a0)+,(a1)+
  55.     adda.w    #160-16,a0
  56.     dbra    d1,s2loop
  57.     rts
  58.  
  59. rightedge adda.w    #160-8,a0 ; we're in the last word of this line
  60. leftedge    move.b    d1,one_word    ; just doing one word
  61.     move.l    a0,firstword    ; save the address for restore
  62. s1loop    move.l    (a0)+,(a1)+
  63.     move.l    (a0)+,(a1)+
  64.     adda.w    #160-8,a0
  65.     dbra    d1,s1loop
  66.     rts
  67.  
  68. clipout    clr.b    mouse_saved
  69.     rts
  70.  
  71.     ;restore_m() restore underneath mouse
  72.     public _restore_m
  73. _restore_m
  74.     tst.b    mouse_saved
  75.     beq    restored
  76.     move.l    #undermouse,a0
  77.     move.l    firstword,a1
  78.     move.w    lines,d1
  79.     tst.b    one_word
  80.     beq    r2loop
  81. r1loop    move.l    (a0)+,(a1)+
  82.     move.l    (a0)+,(a1)+
  83.     adda.w    #160-8,a1
  84.     dbra    d1,r1loop
  85.     bra    restored
  86. r2loop    move.l    (a0)+,(a1)+
  87.     move.l    (a0)+,(a1)+
  88.     move.l    (a0)+,(a1)+
  89.     move.l    (a0)+,(a1)+
  90.     adda.w    #160-16,a1
  91.     dbra    d1,r2loop
  92. restored    clr.b    mouse_saved
  93.     rts
  94.  
  95.  
  96.  
  97.  
  98.  
  99.     bss    mouse_saved,1    ; flag if mouse buffer saved
  100.     bss    one_word,1    ; just one word/line saved?
  101.     bss    lines,2        ; # of lines-1 saved
  102.     bss    firstword,4    ; screen address of first word saved
  103.     bss    undermouse,4*4*16    ; buffer to save under cursor
  104.